package entities;

import java.awt.Color;

/** The Score class for both games. 
 * @author Team 1
 *
 */
@SuppressWarnings("serial")
public class Score extends Entity {
	
	private long points = 0;		//The initial points number.
	
	/** The score's constructor.
	 * @param x : the entity's upper-left corner's x coordinate.
	 * @param y : the entity's upper-left corner's y coordinate.
	 * @param xScale : the x resize scale. If it's lower than one it reduces the images original width, increase it otherwise.
	 * @param yScale : the y resize scale. If it's lower than one it reduces the images original height, increase it otherwise.
	 */
	public Score(int x, int y, float xScale, float yScale) {
		super(x, y);
		this.width = Math.round(185 * xScale);
		this.height = Math.round(15 * yScale);
		setText("Score: " + points);
		setForeground(Color.WHITE);
		setBounds(x, y, width, height);
	}

	public Score(int x, int y, float xScale, float yScale, long points) {
		super(x, y);
		this.width = Math.round(185 * xScale);
		this.height = Math.round(15 * yScale);
		this.points = points;
		setText("Score: " + this.points);
		setForeground(Color.WHITE);
		setBounds(x, y, width, height);
	}
	
	/** Sets and shows points number
	 * @param points : points' value.
	 */
	public void setPoints(long points) {
		//If someone reach long's max value, it wont add more points.
		if(points >= 0) {
			this.points = points;
			setText("Score: " + points);
		} else {
			this.points = Long.MAX_VALUE;
			setText("Score: " + Long.MAX_VALUE);
		}
	}
	
	/** Gets point number
	 * @return points : points' value.
	 */
	public long getPoints() {
		return points;
	}
}
